﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Data;
using UIExample.ViewModel;
using WK35705XML;


namespace UIExample.Converters
{
    class FilterToVisiabilityConverter : IMultiValueConverter
    {
        public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
        {
            if (values == null || values.Count() < 2 || values[0] == null || values[1] == null)
                return Visibility.Visible;
            IOParameterViewModel i = null;

            
            string f = "";
            if (values[0] is string)
            {
                f = values[0] as string;
            }
            if (values[0] is IOParameterViewModel)
            {
                i = values[0] as IOParameterViewModel;
            }

            if (values[1] is string)
            {
                f = values[1] as string;
            }
            if (values[1] is IOParameterViewModel)
            {
                i = values[1] as IOParameterViewModel;
            }
            if (i != null)
            {
                if (i.IO == MainViewModel.MouseOnIO)
                    return Visibility.Visible;
                return i.IO.type != f ? Visibility.Hidden : Visibility.Visible;
            }
            return Visibility.Visible;
        }

        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
        {
            throw new NotImplementedException();
        }
    }
}
